﻿<Page
    x:Class="TestApp.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height=".8*"/>
            <RowDefinition Height=".2*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width=".7*"/>
            <ColumnDefinition Width=".3*"/>
        </Grid.ColumnDefinitions>
        <Grid.Resources>
            <Style x:Key="ListViewItemStyle" TargetType="ListViewItem">
                <Setter Property="Width" Value="400"></Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ListViewItem">
                            <ContentPresenter x:Name="contentPresenter" Width="{TemplateBinding Width}"/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <DataTemplate x:Key="ListViewTemplate">
                <Grid HorizontalAlignment="Stretch" Margin="5,0,0,0"  Background="{Binding ItemBrush}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width=".8*"/>
                        <ColumnDefinition Width=".2*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" Text="{Binding Description}"/>
                    <TextBlock Grid.Column="1" Text="{Binding NumberOfChanges}" TextAlignment="Center"/>
                </Grid>
            </DataTemplate>
        </Grid.Resources>
        <Canvas Name="MainCanvas" Grid.Row="0" Grid.Column="0" Background="White"
                HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin ="0,0,0,0"/>
        <StackPanel Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch">
            <StackPanel Orientation="Horizontal">
                <Button Name="BtnUndo" Content="Undo" IsEnabled="{Binding CanUndo}"/>
                <Button Name="BtnRedo" Content="Redo" IsEnabled="{Binding CanRedo}"/>
            </StackPanel>
            <ListView HorizontalAlignment="Stretch" ItemsSource="{Binding Changesets}" SelectionMode="Single"
                      ItemTemplate="{StaticResource ListViewTemplate}"
                      ItemContainerStyle="{StaticResource ListViewItemStyle}"/>
        </StackPanel>
    </Grid>
</Page>
